package com.whfc.fuum.dao;


import com.whfc.fuum.dto.SysRuleDTO;
import com.whfc.fuum.entity.SysRoleRule;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SysRoleRuleMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(SysRoleRule record);

    int insertSelective(SysRoleRule record);

    SysRoleRule selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(SysRoleRule record);

    int updateByPrimaryKey(SysRoleRule record);


    /**
     * 批量插入
     *
     * @param roleId
     * @param ruleIdList
     * @return
     */
    int batchInsert(@Param("roleId") Integer roleId, @Param("ruleIdList") List<Integer> ruleIdList);


    /**
     * 删除角色关联的权限
     *
     * @param roleId
     */
    int deleteByRoleId(@Param("roleId") Integer roleId);

    /**
     * 删除角色关联的权限
     *
     * @param roleId
     * @param platform
     */
    int deleteByRoleIdAndRulePlatform(@Param("roleId") Integer roleId, @Param("platform") Integer platform);

    /**
     * 删除权限关联
     *
     * @param ruleId
     * @return
     */
    int deleteByRuleId(@Param("ruleId") Integer ruleId);

    /**
     * 查询角色关联的权限列表
     *
     * @param roleId
     * @param platform
     * @return
     */
    List<SysRuleDTO> selectRuleDTOByRoleId(@Param("roleId") Integer roleId, @Param("platform") Integer platform);

    /**
     * 根据权限Code查找角色ID
     *
     * @param ruleCode 权限Code
     * @return 角色ID
     */
    List<Integer> selectRoleIdsByRuleCode(@Param("ruleCode") String ruleCode);

    /**
     * 根据权限ID查找角色ID列表
     * @param ruleId 权限ID
     * @return 角色ID列表
     */
    List<Integer> selectRoleIdsByRuleId(@Param("ruleId") Integer ruleId);
}